﻿#include <iostream>
using namespace std;
int search(int arr[], int len, int key)
{
    int low = 0, high = len - 1, mid;
    while (low <= high)
    {
        mid = (low + high) / 2;
        if (arr[mid] == key) return mid;
        else if (arr[mid] > key) high = mid - 1;
        else low = mid + 1;
    }
    return -1;
}
int main()
{
    int a[5] = { 4,6,7,24,8 };

    if (search(a, 5, 1) >= 0)cout << "查找成功";
    else cout << "查找失败";
}

